package com.pengheng.controller;

import com.pengheng.producer.RocketMQProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MessageController {

    @Autowired
    private RocketMQProducer rocketMQProducer;

    @GetMapping("/send")
    public String sendMessage(@RequestParam String message) {
        rocketMQProducer.sendMessage("test-topic", message);
        return "Message sent: " + message;
    }

    @GetMapping("/delay")
    public String delay(@RequestParam String message, Long time) {
        rocketMQProducer.sendDelayMsg("test-topic", message, time);
        return "Message sent: " + message;
    }



}